'use strict';

module.exports = app => {
    const {STRING, ENUM, TEXT, INTEGER, DATE, NOW} = app.Sequelize;

    const WbUrl = app.model.define('wbUrl', {
        id: {
            type: INTEGER,
            primaryKey: true,
            autoIncrement: true,
        },
        type: {
            type: ENUM('读取列表', '评论'),
            defaultValue: '读取列表',
        },
        screen_name: STRING(255), // 昵称
        wb_uid: STRING(30), // 微博ID
        profile_image_url: STRING(255), // 头像
        profile_url: STRING(300), // 个人主页地址
        content: {
            type: STRING(300),
            defaultValue: '不经过社会的毒打，怎么能懂什么是坚强',
            comment: '自动回复内容'
        }, //评论
        created_at: DATE,
        updated_at: DATE
    });


    WbUrl.findByScreenNameAndType = async function (screen_name, type) {
        return await this.findOne({
            where: {screen_name: screen_name, type: type},
        });
    };

    WbUrl.findById = async function (id) {
        return await this.findOne({
            where: {id: id},
        });
    };

    return WbUrl;
};
